#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, m;
int a, b, c;
int mx_sqrt(int d) {
  int res = 1;
  for (int i = 2; i * i <= d; i++) {
    if (d % (i * i) == 0) res = i;
  }
  return res;
}
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
void out(int p, int q) {
  int d = gcd(abs(p), abs(q));
  p /= d, q /= d;
  cout << p;
  if (q != 1) cout << '/' << q;
}
void out(int p, int q, int r) {
  int d = gcd(abs(p), abs(q));
  p /= d, q /= d;
  if (p != 1) cout << p;
  if (p != 1 && r != 1) cout << '*';
  if (r != 1) cout << "sqrt(" << r << ')';
  if (q != 1) cout << '/' << q;
}
void solve() {
  cin >> a >> b >> c;
  if (a < 0) a *= -1, b *= -1, c *= -1;
  int d = b * b - 4 * a * c;
  if (d < 0) {
    cout << "NO" << endl;
    return;
  } else {
    int x = round(sqrt(d));
    if (x * x == d) {
      out(-b + x, a * 2);
      cout << endl;
    } else {
      if (b) {
        out(-b, a * 2);
        cout << '+';
      }
      x = mx_sqrt(d);
      out(x, a * 2, d / (x * x));
      cout << endl;
    }
  }
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  while (n--) solve();
  return 0;
}